﻿//ajax正在处理请求
$(document).ajaxStart(function() {
    if (document.getElementById("loading"))
        document.body.removeChild(document.getElementById("loading"));
    //$(":input").attr("disabled", true);
    var oTop = document.documentElement.clientHeight / 2 + document.documentElement.scrollTop + "px";
    var oleft = (document.documentElement.clientWidth - 350) / 2 + "px";
    $(document.body).append("<div id=\"loading\" style=\"width:250px;z-index:99999;text-align:center;top:" + oTop + ";left:" + oleft + ";background-color: #f8fbff; border: 1px solid #d1e2f3; padding: 15px; margin: 5px 0; position:absolute;font-size:14px;\"> 正在处理请求，请稍后...... </div>");
});

//ajax出来请求时出错
$(document).ajaxError(function() {
    if (document.getElementById("loading"))
        document.body.removeChild(document.getElementById("loading"));
    var oTop = document.documentElement.clientHeight / 2 + document.documentElement.scrollTop + "px";
    var oleft = (document.documentElement.clientWidth - 350) / 2 + "px";
    $(document.body).append("<div id=\"loading\" style=\"width:350px;z-index:99999;text-align:center;top:" + oTop + ";left:" + oleft + ";background-color: #f8fbff; border: 1px solid #d1e2f3; padding: 15px; margin: 5px 0; position:absolute;font-size:14px;\">错误，刷新本页可能可以解决问题。</div>");

});
//ajax完成请求
$(document).ajaxSuccess(function() {
    if (document.getElementById("loading"))
        document.body.removeChild(document.getElementById("loading"));
    //$(":input").attr("disabled", false);
});
//增加from提交事件
//$(document).ready(function() {
//    $("form").submit(function() {
//        $(":submit").attr("disabled", true);
//        var oTop = document.documentElement.clientHeight / 2 + document.documentElement.scrollTop + "px";
//        var oleft = (document.documentElement.clientWidth - 350) / 2 + "px";
//        $(document.body).append("<div id=\"loading\" style=\"width:250px;z-index:99999;text-align:center;top:" + oTop + ";left:" + oleft + ";background-color: #f8fbff; border: 1px solid #d1e2f3; padding: 15px; margin: 5px 0; position:absolute;font-size:14px;\"> Loading Please Wait...... </div>");
//    });
//});